import Vue from 'vue';
import PluginClass from './plugin';
import { Toast, Button, NavBar, Col, Row, Field, Checkbox, Icon, Dialog, Picker, Popup, Loading, List, Cell, Empty, Pagination, Search } from 'vant';
import pluginConfig  from './pluginConfig';
import 'vant/lib/index.css';
import './styles/global.scss';
import './styles/vant.scss';
import './class-component-hooks';

Vue.config.productionTip = false;

Vue.use(Toast).use(Button).use(NavBar).use(Col).use(Row).use(Field).use(Checkbox).use(Icon).use(Dialog)
  .use(Picker).use(Popup).use(Loading).use(List).use(Cell).use(Empty).use(Pagination).use(Search);

const plugin = new PluginClass();

function installPlugin() {
  const pluginIndex = window.pluginIndex;
  if (pluginIndex) {
    console.log(`轻应用${pluginConfig.appId}初始化并调用pluginIndex.install方法`);
    pluginIndex.install(plugin);
  }
}

/**
 * 初始化加载插件
 */
if (runType === 'dev') {
  plugin.render();
} else {
  installPlugin();
  // runType === 'app' ? installPlugin() : window.addEventListener('load', () => {
  //   installPlugin();
  // })
}
